package com.rongshu.view.userInfo.presenter;

import android.content.Context;

import com.rongshu.api.RetorfitService;
import com.rongshu.view.base.mvp.BasePresenter;
import com.rongshu.view.base.mvp.INetBean;
import com.rongshu.view.userInfo.entity.CollectedArticle;
import com.rongshu.view.userInfo.iview.CollectedArticleView;
import com.utils.LogUtil;

import rx.Subscriber;

public class CollectedArticlePresenter extends BasePresenter<CollectedArticleView> {

    public CollectedArticlePresenter(Context context) {
        super(context);
    }

    /**
     * APP获取文集下的文章列表
     */
    public void getMyArticle(int user_id, int serialize_id, int type,
                             int page, int pagesize, String sign) {
        RetorfitService.getMyArticle(user_id, serialize_id, type, page, pagesize, sign)
                .subscribe(new Subscriber<CollectedArticle>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(CollectedArticle collectedArticle) {
                        if (getView() != null) {
                            getView().onCollectedArticleList(collectedArticle);
                        }
                    }
                });
    }

    /**
     * APP删除文章
     */
    public void getDeleteContribute(int user_id, int contribute_id, String sign) {
        RetorfitService.getDeleteContribute(user_id, contribute_id, sign)
                .subscribe(new Subscriber<INetBean>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(INetBean bean) {
                        if (getView() != null) {
                            getView().onDeleteContribute(bean);
                        }
                    }
                });
    }

    /**
     * APP移动文章
     */
    public void getMoveContribute(int user_id, int contribute_id, int serial_id, String sign) {
        RetorfitService.getMoveContribute(user_id, contribute_id, serial_id, sign)
                .subscribe(new Subscriber<INetBean>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(INetBean bean) {
                        if (getView() != null) {
                            getView().onMoveContribute(bean);
                        }
                    }
                });
    }
}
